<script setup>
import {onMounted} from 'vue'
import {useUserStore} from '@/stores/userStore'
import {adminUserStore} from '@/stores/adminStore'

const userStore = useUserStore()
const adminStore = adminUserStore()

onMounted(() => {
  // 页面加载时校验 Token
  userStore.checkTokenExpiration()
  adminStore.checkTokenExpiration()
})

// 监听页面关闭事件
window.addEventListener('beforeunload', () => {
  if (!userStore.checkTokenExpiration()) userStore.logout()
  if (!adminStore.checkTokenExpiration()) adminStore.logout()
})
</script>

<template>
  <RouterView/>
</template>

<style>
html, body {
  margin: 0;
  padding: 0;
}
</style>
